<!DOCTYPE html>
<html>
	<head>
		<title></title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
		<link rel="stylesheet" href="../res/css/weui.css"/>
		<link rel="stylesheet" href="../res/css/weuix.css"/>
		<link rel="stylesheet" href="../res//css/common.css">
		<link rel="stylesheet" href="../res/css/swiper.css">
		<script src="../res/js/zepto.min.js"></script>
		<script src="../res/js/zepto.weui.js"></script>
		<script src="../res/js/common.js?v=1"></script>
		<script src="../res/js/swiper.js"></script>
		<script src="../res/js/JsBarcode.all.min.js" type="text/javascript"></script>
		<style type="text/css">
			.title >view:last-child {
			    font-size: 18px;
			    margin-top: 15px;
			    position: relative;
			    line-height:20px
			}
			.type_img {
			   display:flex;
			   align-items: center;
			   justify-content: center;
			}
			#btnBuyOrder{
			    border-radius: 10px;
			    background: #1189ff;
			    color: #ffffff;
			}
			.part{
			    border-radius: 10px;
			    background: #ffffff;
			    margin: 0 10px 10px;
			  }
			.viewlist {
			    margin: 0 15px;
			    padding: 15px 0;
			    display: flex;
			    align-items: center;
			    justify-content: space-between;
			    border-bottom: 1px solid #e0e0e0;
			}
			.viewlist:last-child {
			    border-bottom: 0px solid #e0e0e0;
			}
			.tips {
			    padding-left: 15px;
			}
			.tips >span {
			    color: red;
			}
		</style>
		<script type="text/javascript">
			var code = '', doctorId = 0, inquiryType = 0,doctorName='',feePay=0;
			$(function () {
				doctorId = getQst("doctor_id");
				inquiryType = getQst('log_type');
				doctorName = getQst('doctor_name');
				feePay = getQst('feepay');
				setPhoto()
				// 后退    
				$('#btnBack').on('click', function () {
					// goPage("inquiry_doctor_index.htm");
					goPageNo(-1);
				})
			})
			
			function setPhoto(){
				var data1='',data2='';
				$('.doc_Name').html(doctorName);
				$('.pay_fee').html('￥'+feePay);
				$('#btnBuyOrder').html('支付 (¥'+feePay+')');
				if(inquiryType==1){
					//视频
					data1+='<div>您当前问诊类型是</div>'
					data1+='<div><div class="blueBlock"></div>视频问诊</div>'
					data2+='<img class="" src="../res/images/img_video_interrogation.png" mode="widthFix" lazy-load="false" binderror="" bindload=""></img>'
					$('.title').html(data1);
					$('.type_img').html(data2);
				}else{
					//图文
					data1+='<div>您当前问诊类型是</div>'
					data1+='<div><div class="blueBlock"></div>图文问诊</div>'
					data2+='<img class="" src="../res/images/img_image_interrogation.png" mode="widthFix" lazy-load="false" binderror="" bindload=""></img>'
					$('.title').html(data1);
					$('.type_img').html(data2);
				}
			}
			
			function payfee(){
				var params = {
				  "code": 1,
				  "doctorId": doctorId,
				  "inquiryType": inquiryType,
				  "totalFee": parseInt(feePay)
				}
				newAjaxPost("/h5/wxpay/addConsultationFee", params, payfeeOk);
			}
			function payfeeOk(jsonInfo){
				var data = [];
				if(jsonInfo.code == 1){
					data = jsonInfo.data;
					//调起支付
					WeixinJSBridge.invoke(
					    'getBrandWCPayRequest', {
					        "appId": data.appId,     //公众号名称，由商户传入       
					        "timeStamp": data.timeStamp,         //时间戳，自1970年以来的秒数       
					        "nonceStr": data.nonceStr, //随机串       
					        "package": data.packageWx, //"prepay_id=" + 
					        "signType": data.signType,         //微信签名方式:       
					        "paySign": data.paySign    //微信签名   
					    },
					    function (res) {
							// alert(res.err_msg)
					        if (res.err_msg == "get_brand_wcpay_request:ok") {
					            msgInfo("支付成功！");
								strGoUrl = 'inquiry_doctor_feeOK.htm?feepay=' + feePay + '&doctor_id=' + doctorId + '&doctor_name=' + doctorName + '&log_type=' + inquiryType ;
								goPage(strGoUrl);
					        }
					        else
					            msgInfo('用户取消支付');
					    }
					);
					// $('.index_title').html(data);
				}else{
					msgInfo(jsonInfo.msg)
				}
			}
			
			function wxDoPay() {
			     if (typeof WeixinJSBridge == "undefined") {
						msgInfo("此场景无法调起支付！");
			         if (document.addEventListener) {
			             document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
			         } else if (document.attachEvent) {
			             document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
			             document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
			         }
			     } else {
			         payfee();
			     }
			}
		</script>
	</head>
	<body ontouchstart>
	    <div class="fix-top" style="z-index: 100;">
	        <div class="weui-btn_primary weui-header"> 
	            <div class="weui-header-left"><a id="btnBack" class="icon icon-109"></a></div>
	            <h1 class="weui-header-title">问诊付费</h1>
	            <div class="weui-header-right"></div> 
	        </div>
	    </div>
		<div class="part" style="margin-top: 10px;">
			<div class="viewlist">
				<div class="title">
				</div>
				<div class="type_img">
				</div>
			</div>
		</div>
		<div class="part">
			<div class="viewlist">
				<div class="left_title">问诊医生</div>
				<div class="doc_Name">{{name}}</div>
			</div>
			<div class="viewlist">
				<div class="left_title">费用类别</div>
				<div>诊查费</div>
			</div>
			<div class="viewlist">
				<div class="left_title">费用金额</div>
				<div class="pay_fee">￥7</div>
			</div>
		</div>
		<div class="tips"><span>*</span> 温馨提示：当天问诊有效，一次只能问诊同一医生</div>
		<div style="margin: 15px 30px;" >
			<a id="btnBuyOrder" onclick="wxDoPay()" href="javascript:;" class="weui-btn weui-btn_primary" style="font-size:16px;">支付 (¥7)</a>
		</div>
	</body>
</html>
